﻿Public Class FrmChiTietPhieuNhap

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()

    End Sub

    Private Sub btnLapPhieu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLapPhieu.Click
        FrmLapPhieuNhap.ShowDialog()

    End Sub
    Sub LoadLenLuoi()
        ' Dim iMaPhieuNhap As Integer = txtMaPhieuNhap.Text
        Dim ds As DataTable
        ds = PhieuNhapDAO.SelectAll()
        dgvDSChiTietPhieuNhap.DataSource = ds

    End Sub
    Public Sub LoadDSTim()
       Dim iMaPhieuNhap As Integer = txtMaPhieuNhap.Text
        Dim ds As DataTable
        ds = PhieuNhapDAO.SelectAllCTPN(iMaPhieuNhap)
        dgvDSChiTietPhieuNhap.DataSource = ds
    End Sub
    Private Sub FrmChiTietPhieuNhap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadLenLuoi()

    End Sub

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim iMaPhieuNhap As Integer = txtMaPhieuNhap.Text
        Dim pn As PhieuNhapDTO = PhieuNhapDAO.SelectByID(iMaPhieuNhap)

        dtpNgayNhap.Value = pn.NgayNhap

        LoadDSTim()
        LoadTongGiaTriPhieuNhap()
    End Sub

    Public Sub LoadTongGiaTriPhieuNhap()
        Try
            txtTongTien.Text = PhieuNhapDAO.TotalValue(txtMaPhieuNhap.Text) & "VND"
        Catch ex As Exception
            txtTongTien.Text = "0 VND"
        End Try


    End Sub
End Class